# LuckPay Web Manage System
#
# Copyright (c) 2016 Lucky Byte, Inc.
#

$ ->
    # 导航链接
    $('.nav.with.date').click (evt) ->
        evt.preventDefault()
        start_date = $('form input[name=start_date]').val()
        end_date = $('form input[name=end_date]').val()

        location = $(this).data('href') + "?"
        if start_date?
            location += "start_date=#{start_date}&"
        if end_date?
            location += "end_date=#{end_date}"
        window.location = location

    # 指向交易流水的链接
    $('.link.trlist').click (evt) ->
        evt.preventDefault()

        start_date = $('form input[name=start_date]').val()
        end_date = $('form input[name=end_date]').val()

        location = "/trlist?"
        if start_date?
            location += "start_date=#{start_date}&"
        if end_date?
            location += "end_date=#{end_date}&"

        for k in [
            'keyword', 'incoming', 'chnl', 'settl', 'succed', 'trcode'
        ]
            v = $(this).data(k)
            if v? and v isnt '' then location += "#{k}=#{v}&"
        window.location = location
